<template>
    <div>
        <h2>当前求和为：{{$store.state.num}}</h2>
        <select v-model.number="n">
            <option :value="1">1</option>
            <option :value="2">2</option>
            <option :value="3">3</option>
        </select>
        <button @click="add(n)">+</button>
        <button @click="addOdd(n)">当前为奇数再加</button>
    </div>
</template>

<script>
    import {mapState,mapActions} from "vuex"
    export default {
        name:'list',
        data(){
            return {
                n:1,
            }
        },
        computer: {
            ...mapState(['num'])
        },
        methods:{
            ...mapActions(['add', 'addOdd'])
        },
        mounted(){
            
            console.log(mapActions(['add', 'addOdd']))
        }
    }
</script>

<style>
    button{
        margin: 0 5px;
    }
</style>